<template>
  <div id="app">
    <!-- 用来显示路由组件 -->
    <router-view />
  </div>
</template>

<script>
export default {
  name: "App",
  created() {
    //在页面加载时读取sessionStorage里的状态信息
    if (sessionStorage.getItem("store")) {
      this.$store.replaceState(
        Object.assign(
          {},
          this.$store.state,
          JSON.parse(sessionStorage.getItem("store"))
        )
      );
    }
    //在页面刷新时将vuex里的信息保存到sessionStorage里
    window.addEventListener("beforeunload", () => {
      sessionStorage.setItem("store", JSON.stringify(this.$store.state));
    });
  }
};
</script>

<style>
@font-face {
  font-family: "iconfont"; /* project id 1891558 */
  src: url("//at.alicdn.com/t/font_1891558_sai8syntbzk.eot");
  src: url("//at.alicdn.com/t/font_1891558_sai8syntbzk.eot?#iefix")
      format("embedded-opentype"),
    url("//at.alicdn.com/t/font_1891558_sai8syntbzk.woff2") format("woff2"),
    url("//at.alicdn.com/t/font_1891558_sai8syntbzk.woff") format("woff"),
    url("//at.alicdn.com/t/font_1891558_sai8syntbzk.ttf") format("truetype"),
    url("//at.alicdn.com/t/font_1891558_sai8syntbzk.svg#iconfont") format("svg");
}
.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -webkit-text-stroke-width: 0.2px;
  -moz-osx-font-smoothing: grayscale;
}
</style>
